
Ext.define('ZO0.view.shipping.USPSRate', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.uspsrate',

    title: 'Rates',
    store: 'shipping.USPSRate',

    frame: true,
    columnLines: true,
    selType: 'cellmodel',

    initComponent: function() {

        var me = this;

        me.afterEdit = function() {
            var cell = me.getView().getSelectionModel().getSelection()[0];
            cell.commit();
	};
        me.editing = Ext.create('Ext.grid.plugin.CellEditing');
	me.editing.addListener('afteredit', me.afterEdit);

        Ext.applyIf(me, {
            height: 400,
            plugins: [
                me.editing
//                {
//                    ptype: 'datatip',
//                    tpl: 'DoubleClick to edit {weight}'
//                }
            ],
            viewConfig: { stripeRows: true },
            columns: [
                { xtype: 'gridcolumn',   header: 'Weight', dataIndex: 'weight', width: 70, align: 'center', locked: true
                },
                { xtype: 'numbercolumn', header: 'z0',  dataIndex: 'z0', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                },
                { xtype: 'numbercolumn', header: 'z1', dataIndex: 'z1', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                },
                { xtype: 'numbercolumn', header: 'z2', dataIndex: 'z2', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                },
                { xtype: 'numbercolumn', header: 'z3', dataIndex: 'z3', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z4', dataIndex: 'z4', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z5', dataIndex: 'z5', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z6', dataIndex: 'z6', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z7', dataIndex: 'z7', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z8', dataIndex: 'z8', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z9', dataIndex: 'z9', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z10', dataIndex: 'z10', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z11', dataIndex: 'z11', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }, {
                    xtype: 'numbercolumn', header: 'z12', dataIndex: 'z12', width: 70, align: 'right', renderer: 'usMoney', sortable: false, menuDisabled: true,
                    editor: { xtype: 'numberfield', allowBlank: false, minValue: 0, maxValue: 500 }
                }
            ],
            dockedItems: [{
                xtype: 'pagingtoolbar',
                store: 'shipping.USPSRate',
                dock: 'bottom',
                displayInfo: true
            }],
            listeners: {
                render: function(grid) {
                    grid.getStore().load();
                }
            }
        });
        me.callParent(arguments);
    }
});
